<?php
class Log{
	const LOG_ERROR = 'error';
	const LOG_INFO = 'info';
	const LOG_WARNING = 'warning';
	public static function error($tag,$msg){
		$logfile = BASE_PATH . SLASH . Configuration::LOG_FOLDER . SLASH . Configuration::LOG_FILE;
		try {
			$fp = fopen($logfile, 'a+');
			$time = @date('[d/m/Y H:i:s]');
			$str = $time . "\t" . $tag ."\t\t\t\t". Log::LOG_ERROR . "\t" . $msg;
			fwrite($fp, $str.PHP_EOL);
			fclose($fp);
		} catch (Exception $e) {
			if(Configuration::DEBUG_MOD == true){
				print_r($e);
			}
		}
	}
	public static function info($tag,$msg){
		$logfile = BASE_PATH . SLASH . Configuration::LOG_FOLDER . SLASH . Configuration::LOG_FILE;
		try {
			$fp = fopen($logfile, 'a+');
			$time = @date('[d/m/Y H:i:s]');
			$str = $time . "\t" . $tag ."\t\t\t\t". Log::LOG_INFO . "\t" . $msg;
			fwrite($fp, $str.PHP_EOL);
			fclose($fp);
		} catch (Exception $e) {
			if(Configuration::DEBUG_MOD == true){
				print_r($e);
			}
		}
	}
	public static function warning($tag,$msg){
		$logfile = BASE_PATH . SLASH . Configuration::LOG_FOLDER . SLASH . Configuration::LOG_FILE;
		try {
			$fp = fopen($logfile, 'a+');
			$time = @date('[d/m/Y H:i:s]');
			$str = $time . "\t" . $tag ."\t\t\t\t". Log::LOG_WARNING . "\t" . $msg;
			fwrite($fp, $str.PHP_EOL);
			fclose($fp);
		} catch (Exception $e) {
			if(Configuration::DEBUG_MOD == true){
				print_r($e);
			}
		}
	}
}